package com.ipartek.formacion.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CheckTheEmail {

	/**
	 * Checkea si el email es corecto
	 * 
	 * @param email
	 * @return verdadero si email correcto
	 */
	public static boolean CheckEmail(String email) {
		if (email != null) {
			try {
				Pattern pat = Pattern
						.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
								+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
				Matcher mat = pat.matcher(email);
				if (mat.find()) {
					return true;
				} else {
					return false;
				}
			} catch (Exception e) {
				return false;
			}

		} else {
			return false;
		}
	}

}
